{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\software\\Anaconda3\\lib\\site-packages\\sklearn\\cross_validation.py:553: Warning: The least populated class in y has only 1 members, which is too few. The minimum number of labels for any class cannot be less than n_folds=3.\n",
      "  % (min_labels, self.n_folds)), Warning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Best test score: 0.9648\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEYCAYAAABRB/GsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xd4FNX6wPHvm0IPVYq0AFIUVBBEUPAaBUWUohQbWBAJ2K6K7XpRxILXq3itgIaOhIsd8GcBUXMVBYQEEUQpIkHAUAIEkgAhyfv7Y5aYsrvZkN20fT/Ps09mZ8+cOWeTnHfmnJkzoqoYY4wJXiGlXQBjjDGlywKBMcYEOQsExhgT5CwQGGNMkLNAYIwxQc4CgTFBSESqikhoaZfDlA0WCIwpg0Rkoojc4GZ9JRF5RkTCTyHPGSJyj+vtF0BvD+kaichNud6fISL3u5YteFRAFghKkIhMEJFUETkkIl+LyNnFzO9VEbk+UOk9bJ8kIhkicsC13PpU8/Owj8tF5HcR2SEid+f7bIKITPDn/vLl/5CIPORmfTcR+VVE9orIw7nWXy8irxZzn+tF5DsR+UFEnnatawBcA9yVv8FX1QygDfCyq8H+TUTWiUi8iPwsImtEZIOIzHazu2PAYdfycdfLnWigc673NYBbRaQdsFxEqp5qfYtDRGaLyG1+zK+FiGz3V37lmqraq4RewATgeSAceALYAVQu7XKdQj3igCsDkG8dYA9wAVAT+A04M9/3N6EU6vsRcLNruV4A6lwD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a1bNxISErjxxhu57rrrSE5O5rbbbuOmm25i8+bNOfklJiby+uuvU716dc477zwef/zxPP3xqamp1KxZkxUrVrB37162bNlCYmIi1atXJzQ0lOzsbLKzC3tMqzHG/KXcXjVUJLGxEB0N6a5neSQmOu8Bhg0rVta9evWiZs2aVK5cmezsbLKysli0aBFt27YlLCyMEydOsHbtWu655x4GDhzIsmXLGDJkCIsWLaJGjRoF8rv33nt57rnnEBEaNmzI8OHDGTZsGAsWLCA8PJyUlBSSk5N544036NSpExdddBFvvPEGW7du5W9/+xtbt25l4cKFXHDBBcWqlzEmeFSMQHD//fDjj54/X7kS8vfJp6fDyJEwbZr7bTp1glde8brbmJgYPv74Y3r37k3Xrl1z1uceTF2wYAHJyckMGjSIa6+9losvvpi9e/fSo0cPnn/+efr2/euphC+//DK1a9fmiiuuyFl33333sWvXLnr06MH06dNp0KAB27dv58EHH2TTpk0kJSXx008/MXHiRFq3bs1bb71lQcAYUyQVIxAUxtPAbDEHbKOjo2nfvj1Lly4F4OjRo4SF5f1Kb7nlFq688kqee+457rnnHnbv3s3AgQNZsWIF4eHhZGZmEhYWRmJiIl999RVt27bl7LPPZv/+/bRs2TKn3/+ee+4hLS2NzMxMnnzySd5++23Gjh1LeHg4//znP4mPj6dSpUq0atWqWHUyxgSfihEICjlyp0ULpzsov8hIiIsr9u5DQpyhlm3btjF48OA8n4kIkyZNYuzYsWzYsIENGzawbt06tm/fTkREBBEREXz00UdERkby8ccfA9ClSxe2bt3K+PHjSUxMZOzYsdx6660AfPfddzz++ONs2bKFdevW8eOPP/L7778zaNAggDxnGMYY44uKEQgKM3Fi3jECgGrVnPV+kJKSwldffcXmzZtp06ZNns82bdrEpk2bmDt3Lr169WLGjBksWrSI1NRUatWqRXh4eIGxgvfff59HH30UgN27d9OsWbOcz3r06MF1113HypUr6du3Lx06dCA8PJzOnTuzcOFCxo8f75c6GWOCR0CuGhKRhiLyrZfPw0XkYxH5TkRuD0QZ8hg2DGJinDMAEednTEyxB4rBuR9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/g/nG6e4SLS1MO2LwCPA1/gjDmA0/g/JCLf4XQZ7XGt7+da96uqnjx7+AIY5Fp/sX+rZUzR2eyjxgSIa7B4gqpuL+WiGOOVBQJjPBCRRsCCfKs3qero0iiPMYFigcAYY4KcjREYY0yQs0BgjDFBzgKBMcYEOQsExhgT5CwQGGNMkPt/CX7Nc8qmFP8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "%matplotlib inline\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "filepath = 'test.xls'\n",
    "\n",
    "data = pd.read_excel(filepath, encoding='utf-8')\n",
    "\n",
    "data.loc[(data[u'空气等级']=='I'),u'空气等级']=1\n",
    "data.loc[(data[u'空气等级']=='II'),u'空气等级']=2\n",
    "data.loc[(data[u'空气等级']=='III'),u'空气等级']=3\n",
    "data.loc[(data[u'空气等级']=='IV'),u'空气等级']=4\n",
    "data.loc[(data[u'空气等级']=='V'),u'空气等级']=5\n",
    "data.loc[(data[u'空气等级']=='VI'),u'空气等级']=6\n",
    "data.loc[(data[u'空气等级']=='VII'),u'空气等级']=7\n",
    "\n",
    "dataT = data.values\n",
    "#data.to_excel('data.xls')\n",
    "\n",
    "# 划分训练集和测试集\n",
    "from sklearn.cross_validation import train_test_split\n",
    "train,test,train_target,test_target=train_test_split(dataT[:,:6],dataT[:,6],test_size = 0.2)\n",
    "train_target=train_target.astype(int)\n",
    "test_target=test_target.astype(int)\n",
    "\n",
    "#构建决策树模型\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.cross_validation import cross_val_score\n",
    "\n",
    "clf = DecisionTreeClassifier(max_depth=8)\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "from sklearn.learning_curve import learning_curve\n",
    "def plot_learning_curve(estimator, X, y, ylim=(0, 1.1), cv=3,\n",
    "                        n_jobs=1, train_sizes=np.linspace(.1, 1.0, 5),\n",
    "                        scoring=None):\n",
    "    plt.rcParams['font.sans-serif']=['SimHei']\n",
    "    plt.rcParams['axes.unicode_minus'] = False\n",
    "    plt.title(\"%s —学习曲线\" % type(estimator).__name__)\n",
    "    plt.ylim(*ylim); plt.grid()\n",
    "    plt.xlabel(\"训练集\")\n",
    "    plt.ylabel(\"分数\")\n",
    "    train_sizes, train_scores, validation_scores = learning_curve(\n",
    "        estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes,\n",
    "        scoring=scoring)\n",
    "    train_scores_mean = np.mean(train_scores, axis=1)\n",
    "    validation_scores_mean = np.mean(validation_scores, axis=1)\n",
    "\n",
    "    plt.plot(train_sizes, train_scores_mean, 'o-', color=\"r\",\n",
    "             label=\"训练分数\")\n",
    "    plt.plot(train_sizes, validation_scores_mean, 'o-', color=\"g\",\n",
    "             label=\"交叉验证分数\")\n",
    "    plt.legend(loc=\"best\")\n",
    "    print(\"最好的测试分数为：{:.4f}\".format(train_scores_mean[-1]))\n",
    "\n",
    "plot_learning_curve(clf, train, train_target) \n",
    "\n",
    "\"\"\"\n",
    "#利用validation_curve计算不同深度训练集和测试集交叉验证得分\n",
    "from sklearn.learning_curve import validation_curve\n",
    "def plot_validation_curve(estimator, X, y, param_name, param_range,\n",
    "                          ylim=(0, 1.1), cv=3, n_jobs=1, scoring=None):\n",
    "    plt.rcParams['font.sans-serif']=['SimHei']\n",
    "    plt.rcParams['axes.unicode_minus'] = False\n",
    "    estimator_name = type(estimator).__name__\n",
    "    plt.title(\" %s验证曲线%s \"\n",
    "              % (estimator_name,param_name))\n",
    "    plt.ylim(*ylim); plt.grid()\n",
    "    plt.xlim(min(param_range), max(param_range))\n",
    "    plt.xlabel(param_name)\n",
    "    plt.ylabel(\"分数\")\n",
    "\n",
    "    train_scores, test_scores = validation_curve(\n",
    "        estimator, X, y, param_name, param_range,\n",
    "        cv=cv, n_jobs=n_jobs, scoring=scoring)\n",
    "\n",
    "    train_scores_mean = np.mean(train_scores, axis=1)\n",
    "    test_scores_mean = np.mean(test_scores, axis=1)\n",
    "    plt.semilogx(param_range, train_scores_mean, 'o-', color=\"r\",\n",
    "                 label=\"训练分数\")\n",
    "    plt.semilogx(param_range, test_scores_mean, 'o-', color=\"g\",\n",
    "                 label=\"交叉验证分数\")\n",
    "    plt.legend(loc=\"best\")\n",
    "    print(\"Best test score: {:.4f}\".format(test_scores_mean[-1]))\n",
    "\n",
    "clf = DecisionTreeClassifier(max_depth=8)\n",
    "param_name = 'max_depth'\n",
    "param_range = [1, 2, 3, 4, 5, 6,7,8,9,10,11,12,13,14,15]\n",
    "\n",
    "plot_validation_curve(clf, train*30, train_target,\n",
    "                      param_name, param_range)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
